package com.hexinfo.dmpro.sparing.dto;

import cn.hutool.core.io.file.FileAppender;
import com.hexinfo.dmpro.component.comparison.enums.TableContrastEnums;
import com.hexinfo.dmpro.sparing.model.HdfsHeatBackup;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 调用DistCP实体类
 * 调用所有DistCP方法的传参
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class DistCPDTO {

    //同步的源名
    private String sourceDataName;
    //hdfs信息
    private HdfsHeatBackup hdfsHeatBackup;
    //表的总hdfs路径数量
    private Integer hdfsFileSize;
    //总日志缓存对象
    private FileAppender heatlog;
    //表的日志缓存对象
    private FileAppender tableLog;

    //源、无源
    public String getBackupSort(){
        return hdfsHeatBackup.getBackupSort();
    }

    //文件大小
    public Long getFileSize(){
        return hdfsHeatBackup.getFileSize();
    }

    //源key
    public String keyMap(){
        if (getBackupSort().equals("1")){
            return sourceDataName+"."+hdfsHeatBackup.getSourceDbName() + "." + hdfsHeatBackup.getSourceTableName();
        }else {
            return sourceDataName+"."+hdfsHeatBackup.getBackupDbName() + "." + hdfsHeatBackup.getBackupTableName();
        }
    }

    //源-->备份
    public String getSouToBack(){
        return hdfsHeatBackup.getSourceAddress() + " " + hdfsHeatBackup.getBackupAddress();
    }

    //备份-->目标
    public String getBackToTar(){
        return hdfsHeatBackup.getBackupAddress() + " " + hdfsHeatBackup.getTargetAddress();
    }

    //源-->目标
    public String getSouToTar(){
        return hdfsHeatBackup.getSourceAddress() + " " + hdfsHeatBackup.getTargetAddress();
    }

    //源--库.表
    public String getSourceName(){
        return hdfsHeatBackup.getSourceDbName() + "." + hdfsHeatBackup.getSourceTableName();
    }
    //备份--库.表
    public String getBackupName(){
        return hdfsHeatBackup.getBackupDbName() + "." + hdfsHeatBackup.getBackupTableName();
    }
    //目标--库.表
    public String getTargetName(){
        return hdfsHeatBackup.getTargetDbName() + "." + hdfsHeatBackup.getTargetTableName();
    }
}
